<?php
    class ArticleModel extends RelationModel{

		protected $_link = array(

			'article_attach'=>array(
				'mapping_type'=> HAS_ONE,
				'foreign_key'=>'articleid',
			),
			
			'hits'=>array(
				'mapping_type'=> HAS_ONE,
				'foreign_key'=>'content_id',
			),

            'files'=>array(
                'mapping_type'=> HAS_MANY,
                'class_name'=>'files',
                'foreign_key'=>'articleid',
                'mapping_order'=>'id desc'
            ),  

            'picurl'=>array(
                'mapping_type'=> HAS_MANY,
                'foreign_key'=>'picid',
                'mapping_order'=>'pid desc'
            ),

            'videourl'=>array(
                'mapping_type'=> HAS_MANY,
                'foreign_key'=>'articleid',
                'mapping_order'=>'videoid desc'
            ),  



		);

        protected $_validate = array(
            array('title','require','标题不能为空！'),
            array('content','require','内容不能为空！')
        );

        protected $_auto = array(
            array('addtime','strtotime',3,'function'),
        );



    }
